class Solution:
    def twoSum(self, nums, target):
        """
        :type nums: List[int]
        :type target: int
        :rtype: List[int]
        """
        ret = []
        nums_dict = {}
        for i, n in enumerate(nums):
            nums_dict[n] = nums_dict.get(n, []) + [i]

        for i in range(len(nums)):
            n = target - nums[i]
            indices = nums_dict.get(n, []) + []

            if indices:
                if i in indices:
                    indices.remove(i)
                if indices:
                    ret = [i, indices[0]]

        return ret
